
var CreateBrushlist = function ()
{
    var htm=[];
    var pattern = '<img usemap="#green" src="working/brushlist/(0)/(1)"' +
                  ' width="200" height="90" border=0' +
                  ' onload="Controller.scroller.invoke ()">';
    htm.push (pattern.format(Controller.brush, new Date().getTime()));
    htm.push (CreateImageMap());
    return htm.join ('');
}

var CreateToolbox = function ()
{
    var htm=[], i=0;
        htm.push ('<div align="center"><table cellspacing="1" bgcolor="gray"><tr>');
        for (var e in Tools)
            if (Tools[e].Icon)
            { 
                htm.push (Tools.Draw(e));
                i++;
                if (i%4==0) htm.push ('</tr><tr>');
            }
        htm.push ('</tr></table></div>');

        htm.push ('<table>');
        htm.push ('<tr>');
        htm.push ('<td style="border:inset 1px" bgcolor="(0)">'.format(Controller.color));
        htm.push ('<img src="/webservices/images/clear.gif" width="24" height="24"/></td>');
        htm.push ('<td bgcolor="#FFFFFF">');
        htm.push ('Forecolor: #<a href="#">(0)</a></td>'.format(Controller.color));
        htm.push ('</tr>');
        htm.push ('<table>');
    return htm.join ('');
}

var Panel = {
    states : { DOCKED:1, EXPANDED:2, FLOATING:4, SPECIAL:8, DEFAULT:16 }
}
var PanelEngine = {
    Restate : function (name, value)
    {
        this.UI[name].state = this.UI[name].state & value ?
              this.UI[name].state - value :
              this.UI[name].state - (-value);
        Controller.UpdateSidebar.invoke();
    },
    UI : {
        Toolbox : {
             caption : 'Tools',
             state   : Panel.states.DOCKED + Panel.states.EXPANDED + Panel.states.SPECIAL + Panel.states.DEFAULT,
             create  : CreateToolbox
        },
        Colorlist : {
             caption : 'Color',
             state   : Panel.states.DOCKED + Panel.states.EXPANDED + Panel.states.SPECIAL,
             create  : CreateColorTable
        },
        Brushlist : {
             caption : 'Brushes',
             state   : Panel.states.DOCKED + Panel.states.EXPANDED + Panel.states.SPECIAL,
             create  : CreateBrushlist
        },
        Zoompane : {
             caption : 'Zoom',
             state   : Panel.states.DOCKED + Panel.states.EXPANDED,
             create  : CreateThumbnailWindow
        },
        Historylog : {
             modes   : {LIST:1,PREVIEW:2},
             mode    : 1,
             caption : 'History',
             state   : Panel.states.DOCKED,
             create  : CreateLogWindow
        },
        ObjectProps : {
             caption : 'Object Properties',
             state   : Panel.states.DOCKED,
             create  : function ()
             {
                 return 'Not ready.';
             }
        }
    }
} 
